﻿#region Header

/*
Behavioral Rating of Dancing Human Crowds based on Motion Patterns
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;

#endregion

namespace paravili.Ui {
	/// <summary>
	/// Description of the class
	/// </summary>
	public class GeneralTemplateSelector : DataTemplateSelector {
		#region Public Properties

		public ObservableCollection<TemplateEntry> Templates { get; set; }

		#endregion

		#region Public Methods

		public GeneralTemplateSelector() {
			Templates = new ObservableCollection<TemplateEntry>();
		}

		public override DataTemplate SelectTemplate(object item, DependencyObject container) {
			if (item == null) {
				return base.SelectTemplate(item, container);
			}
			Type t = item.GetType();
			foreach (TemplateEntry template in Templates) {
				if (template.DataTemplate.DataType == t) {
					return template.DataTemplate;
				}
			}
			return base.SelectTemplate(item, container);
		}

		#endregion

		#region Private Methods

		// private methods located here

		#endregion

		#region Private Fields

		// private fields located here

		#endregion
	}

	public class TemplateEntry {
		public DataTemplate DataTemplate { get; set; }
	}
}